n = int(input())
ans = []
count = 0
while len(ans) < n:
    arry = list(map(int,input().split()))
    for i in arry:
        ans.append(i)
for i in range(n):
    for j in range(i):
        if ans[i] < ans[j]:
            count+=1
print(count)